from exts import db
from common import constant
from common.base_model import BasicModelMixin, CompanyMixin, CreateMixin, UpdateMixin, DeleteMixin

MIDDLE_DB_STR_LEN = constant.MIDDLE_DB_STR_LEN
LONG_DB_STR_LEN = constant.LONG_DB_STR_LEN
COMMON_DECIMAL = constant.COMMON_DECIMAL


class Category(db.Model, BasicModelMixin, CompanyMixin, CreateMixin, UpdateMixin, DeleteMixin):
    __tablename__ = 'category'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(MIDDLE_DB_STR_LEN), nullable=False)
    parent_id = db.Column(db.Integer, db.ForeignKey('category.id'))